<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDevicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('devices', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary();
            $table->unsignedBigInteger('user_id')->default(0)->comment('作者');
            $table->string('cover',255)->nullable()->default('')->comment('最新设备图');
            $table->string('name',255)->default('')->comment('设备名称');
            $table->unsignedBigInteger('device_group_id')->default(0)->comment('所属分组id 为空则不分成');
            $table->unsignedBigInteger('device_order_id')->default(0)->comment('设备所属订单');
            $table->enum('status',['SHIPPED','INSTALLED','IDLE','USING','FAULT','REPAIR','SCRAP','DORMANT'])->default('SHIPPED')->comment('SHIPPED待安装INSTALLED已安装IDLE闲置中USING使用中FAULT故障REPAIR维修ARCHIVE仅归档SCRAP报废DORMANT休眠');
            $table->enum('style',['TEA_HOUSE','INTERNET_CAFE'])->default('INTERNET_CAFE')->comment('款式 TEA_HOUSE茶楼 INTERNET_CAFE网吧');
            $table->string('mac_address',255)->default('')->comment('设备mac地址');
            $table->string('unique_id',64)->default('')->comment('设备唯一id')->index('uuid');
            $table->string('connection_password',64)->default('')->comment('设备连接密码');
            $table->string('province',255)->nullable()->comment('省');
            $table->string('city',255)->nullable()->comment('市');
            $table->string('area',255)->nullable()->comment('区');
            $table->dateTime('recent_usage_time')->nullable()->comment('最近消费时间');
            $table->dateTime('recent_repair_time')->nullable()->comment('最近维护时间');
            $table->timestamps();
            $table->softDeletes();
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('devices');
    }
}
